package cn.icanci.ladybird.controller;

import cn.icanci.ladybird.common.result.JsonData;
import cn.icanci.ladybird.pojo.dto.AdminOrderInfoDTO;
import cn.icanci.ladybird.pojo.dto.UserBuyerTicketDTO;
import cn.icanci.ladybird.service.admin.AdminOrderInfoService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: zxp
 * @date: Created in 2020/10/8 0008 下午 15:38
 * @classAction: 管理员和订单列表数据和分页
 */

@Controller
@Slf4j
@RequestMapping("/api/v1/pri/admin")
public class AdminOrderInfoController {

    @Autowired
    private AdminOrderInfoService adminOrderInfoService;
    /**
     * 跳转到 order-list 票列表
     *
     * @param model 数据处理对象
     * @return 返回视图地址
     */
    @RequestMapping("/orders-list")
    public String adminTicketList(Model model, Integer pageNum, Integer pageSize) {
        // 页面参数，然后在Service进行分页
        PageInfo<AdminOrderInfoDTO> ticketDetailsPageInfo = adminOrderInfoService.queryAllByNotObject(pageNum, pageSize);
        JsonData jsonData = JsonData.builderSuccess(ticketDetailsPageInfo);
        model.addAttribute("jsonData", jsonData);
        return "admin/order-list";
    }

    @RequestMapping("/orders-setting")
    public String getUserIndexJson(Model model,Long orderInfoId){
        AdminOrderInfoDTO adminOrderInfoDTO = adminOrderInfoService.queryByOrderInfoId(orderInfoId);
        JsonData jsonData = JsonData.builderSuccess(adminOrderInfoDTO);
        model.addAttribute("jsonData",jsonData);
        return "admin/order-info";
    }
}
